<template>
  <div class="main-header">
    <div class="logo"><img src="@Images/wandou.jpg" alt="" srcset=""></div>
    <div class="logout" @click="handleLogOut">退出登录</div>
  </div>
</template>

<script setup>
  import { getCurrentInstance } from 'vue'
  import { removeToken, removeCompanyId } from '@/utils/auth'

  defineOptions({
    name: 'main-header'
  })

  // 初始化
  const { appContext, ctx } = getCurrentInstance()
  const { $router, $store, $message } = appContext.config.globalProperties

  const handleLogOut = () => {
      removeToken()
      removeCompanyId()
      $message({ message: '操作成功！', type: 'success' })
      setTimeout(() => {
        window.location.reload()
      }, 3000)      
  }

</script>

<style scoped lang="scss">
  .main-header {
    height: 100%;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    .logo {
      height: 40px;
      width: 40px;
      img {
        display: block;
        width: 100%;
        height: 100%;
        transform: scale(100%) rotate(0deg);
      }
    }
    .logout {
      color: #333;
      height: 40px;
      line-height: 40px;
      padding: 0 10px;
      font-weight: bold;
      cursor: pointer;
    }
  }
</style>